local function AutoComplete(commandName,args)
	local name = string.Explode(' ',args)
	
	name=name[#name] or ""

	local path = string.GetPathFromFilename(name)

	local candidates=file.Find("gamemodes/melonracer/gamemode/"..(name or "").."*",true)
	for i,_ in pairs(candidates) do
		candidates[i]=commandName.." "..path..candidates[i]
	end

	return candidates
	
end	

if SERVER then
	concommand.Add("file_reload_sv", function(_,_,src)		
		GM = GAMEMODE
		MsgN("Reloading (" .. src[1] .. ")...")
		include("melonracer/gamemode/"..src[1])
		//RunString(file.Read("gamemodes/melonracer/"..src[1],true))
		GM = nil
	end,AutoComplete)
	/*concommand.Add("file_reload_cl", function(ply,cmd,args)
		MsgN("Reloading (" .. args[1] .. ")...")
		datastream.StreamToClients( player.GetAll(), "file_reload", { file.Read( "gamemodes/melonracer/" .. args[1] ,true ) } )
	end,AutoComplete)*/
else
	concommand.Add("file_reload", function(ply,cmd,args)
		GM = GAMEMODE
		MsgN("Reloading (" .. args[1] .. ")...")
		include("melonracer/gamemode/"..args[1])
		//RunString(file.Read("gamemodes/melonracer/"..args[1],true))
		RunConsoleCommand("file_reload_sv",args[1])
		GM = nil
	end,AutoComplete)
	/*datastream.Hook( "file_reload", function( handler, id, encoded, decoded )
		GM = GAMEMODE
		RunString(decoded[1])
		GM = nil
	end	);*/
end


